package cn.itcast.order.web;

import cn.itcast.order.pojo.Order;
import cn.itcast.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/order")
public class OrderController {

   @Autowired
   private OrderService orderService;
    /**
     * 路径： /order/101
     *
     * @param orderId 订单ID
     * @return 用户
     */
    @GetMapping("/{orderId}")
    public Order queryOrderByUserId(@PathVariable("orderId") Long orderId,
                                    HttpServletRequest request) {
        // 根据id查询订单并返回
        String message = request.getHeader("message");
        String token = request.getHeader("token");
        System.out.println(message);
        System.out.println(token);
        return orderService.queryOrderById(orderId);
    }
}
